Plotly examples from Saurav Kaushik (https://www.analyticsvidhya.com/blog/2017/01/beginners-guide-to-create-beautiful-interactive-data-visualizations-using-plotly-in-r-and-python/)

To see an io slide version click on this link: https://markspoto.github.io/PlotlyExamples/PlotlyExamplesSlides.html#1

Load Libraries

library(plotly)

Plot Code

Histogram

hist <- plot_ly(x=Sepal.Length, type='histogram')

# defining labels and title using layout()
layout(hist, title = "Iris Dataset - Sepal.Length",
       xaxis = list(title = "Sepal.Length"),
       yaxis = list(title = "Count"))

Figure 1

Boxplot

box_plot <- plot_ly(y=Sepal.Length, type='box', color=Species)
layout(box_plot, title = "Iris Dataset - Sepal.Length Boxplot",
       yaxis = list(title="Sepal.Length"))

Figure 2

Scatter Plot

scatter_plot <- plot_ly(x = Sepal.Length, y=Sepal.Width, type='scatter', mode='markers', color=Species)
layout(scatter_plot, title = "Iris Dataset - Sepal.Length vs Sepal.Width",
       xaxis = list(title = "Sepal.Length"),
       yaxis = list(title = "Sepal.Width"))

Figure 3

Time Series

data("AirPassengers")
time_series <- plot_ly(x=time(AirPassengers), y=AirPassengers, type="scatter", mode="lines")
layout(time_series, title = "Iris Dataset - AirPassengers Dataset - Time Series Plot",
       xaxis = list(title = "Time"),
       yaxis = list(title = "Passengers"))

Figure 4

Heat map

data("volcano")
plot_ly(z=~volcano, type="heatmap")

Figure 5